<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix"><span>登录的界面</span></div>
        
          <el-form ref="form" :model="user" label-width="80px">
            <el-form-item label="账号">
              <el-input v-model="user.tel"></el-input>
            </el-form-item>
            <el-form-item label="密码">
              <el-input v-model="user.password" show-password></el-input>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="onSubmit">登陆</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>
        
      
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
        user:{}
    };
  },
  methods: {
    onSubmit(){
        this.$axios.post("user/login",this.user).then(res=>{
            if(res.data.code==200){
                alert("登陆成功！");
                this.$router.push("/Admin");
            }else{
                this.$message.error("登陆失败!用户名或密码错误")
            }
        }).catch(error=>{
            this.$message.error("系统错误，稍后重试");
        })
    }
  },
};
</script>
<style>
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
  margin: 100px auto;
}
</style>